// pages/personal/get-phone.js
const app = getApp()
Page({

    data: {},

    onLoad: function() {
        // wx.login({
        //     success: res => {
        //         this.code = res.code
        //     }
        // })
    },
    //授权
    getPhoneNumber(e) {
        if (e.detail.errMsg == 'getPhoneNumber:ok') {
            app.http.post('rest/member/decryptMobile.do', {
                data: {
                    // "code": this.code,
                    "encryptedData": e.detail.encryptedData,
                    "iv": e.detail.iv
                }
            }).then(res => {
                wx.setStorage({
                    key: 'mobile',
                    data: res.obj,
                })
                wx.showToast({
                    icon: 'none',
                    title: '绑定成功',
                    success: res => {
                        wx.navigateBack({
                            delta: 1
                        })
                    }
                })
            })
        }
    },
    toMobileCode: function() {
        wx.navigateTo({
            url: '/pages/personal/mobile-input',
        })
    },

})